/*
 * Copyright (C) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.mapbox.ohos.gestures.testapp;

import com.mapbox.ohos.gestures.OhosGesturesManager;

import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.Set;

/**
 * @since 2021-07-15
 */
public class ExclusiveSetSpinnerObject {
    private final Set<Integer> exclusiveSet = new LinkedHashSet<>();

    ExclusiveSetSpinnerObject(Integer... exclusives) {
        this.exclusiveSet.addAll(Arrays.asList(exclusives));
    }

    @Override
    public String toString() {
        StringBuilder builder = new StringBuilder();
        builder.append("(");
        boolean isNotFirst = false;
        for (int gestureType : exclusiveSet) {
            if (isNotFirst) {
                builder.append(", ");
            } else {
                isNotFirst = true;
            }

            builder.append(getStringForType(gestureType));
        }
        builder.append(")");

        return builder.toString();
    }

    private String getStringForType(int gestureType) {
        switch (gestureType) {
            case OhosGesturesManager.GESTURE_TYPE_SCROLL:
                return "Scroll";
            case OhosGesturesManager.GESTURE_TYPE_ROTATE:
                return "Rotate";
            case OhosGesturesManager.GESTURE_TYPE_SCALE:
                return "Scale";
            case OhosGesturesManager.GESTURE_TYPE_QUICK_SCALE:
                return "QuickScale";
            case OhosGesturesManager.GESTURE_TYPE_SHOVE:
                return "Shove";
            case OhosGesturesManager.GESTURE_TYPE_SIDEWAYS_SHOVE:
                return "Sideways shove";
            case OhosGesturesManager.GESTURE_TYPE_MOVE:
                return "Move";
            case -1: // (none)
            default:
                return "none";
        }
    }

    Set<Integer> getExclusiveSet() {
        return exclusiveSet;
    }

}
